<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function format(f, ...args) {
            let i = 1;
            const len = args.length;
            const str = String(f).replace(/%[sdj%]/g, x => {
                if (x === '%%') return '%';
                if (i >= len) return x;
                switch (x) {
                    case '%s':
                        return String(args[i++]);
                    case '%d':
                        return Number(args[i++]);
                    case '%j':
                        return JSON.stringify(args[i++]);
                    default:
                        return x;
                }
            });

            return str;
        }

        format('{"M":"%s", "F":"%s", "T":"%s", "FW":"%s", "TP":"%s", "TM":%d, "SQ":%d, "ST":%d}',
            msg, this.pid, t, fw || '', tp || '', tm, sq || '', st || '');
    </script>
</body>

</html>